<?php 
class Hd{
	
	public static function run(){
		if(!is_dir("App")){
			//	创建模板目录
			self::createDir();
//			复制文件
			self::copyFile();
		}
		//3.载入框架的核心文件
		self::loadCore();
//		4.执行应用
		\Hdphp\Libs\App::run();
	}
	private static function loadCore(){
//		载入函数
		require 'Hdphp/Libs/functions.php';
//		载入总控制器
		require 'Hdphp/Libs/Controller.php';
//		载入App应用类
		require 'Hdphp/Libs/App.php';
	}
	private static function copyFile(){
		//复制用户配置项文件
		copy("Hdphp/Common/Config.php", "App/Home/Config/Config.php");
		//复制控制器文件，用来展示欢迎页面，给用户提供开发模板
		copy("Hdphp/Common/IndexController.php", "App/Home/Controller/IndexController.php");
		//复制模板文件
		copy("Hdphp/Common/index.html", "App/Home/View/Inedx/index.php");
		//成功失败模板
		copy("Hdphp/Common/success.html", "Pudlic/success.html");
		copy("Hdphp/Common/error.html", "Pudlic/error.html");
	}
//	创建模板目录
	private static function createDir(){
		$dirArr=[
			"App/Home/Controller",
			"App/Home/Config/",
			"App/Home/View/Inedx",
			"Pudlic"
		];
		foreach ($dirArr as $k => $v) {
			is_dir($v) || mkdir($v,0777,true);
		}
	}
}
Hd::run();
